
/**
 * 生成SQL查询语句
 */
Ext.define('ExamineItemBuilder', {
	extend : 'Ext.window.Window',
	layout : 'fit',
	modal : true,
	maximizable : true,
	title : '自定义复杂指标编辑器',
	iconCls : 'btn-mail_reply',
	height : 600,
	width : 950,
	buttonAlign : 'center',

	initComponent : function() {		
		this.items = [{
			id: 'mytextarea',
			xtype: 'textarea'
		}];
		this.buttons = [{
					text : '确定',
					iconCls : 'btn-ok',
					scope : this,
					handler : this.save
				}, {
					text : '关闭',
					iconCls : 'btn-cancel',
					scope : this,
					handler : this.cancel
				}];
				
		this.on("boxready", function() {
				var textarea = Ext.getCmp('mytextarea');
                this.codemirror = CodeMirror.fromTextArea(textarea.inputEl.dom,{
                    lineNumbers: true,
			        matchBrackets: true,
			        indentUnit: 4,
			        mode: "text/x-java"
                });
                this.codemirror.setSize('height', this.height - 80);
			});
		this.on("resize", function() {
                this.codemirror.setSize('height', this.height - 80);
			});
		
		this.callParent();
		if(this.textarea.getValue() && this.groovyCode.getValue()) {
			Ext.getCmp('mytextarea').setValue(this.groovyCode.getValue());
		}
	},
	// 取消
	cancel : function() {
		this.close();
	},	
	// 确定
	save: function() {				
		// 显示内容
		if(this.textarea && this.groovy && this.groovyCode) {
			this.textarea.setValue("已设置为【自定义复杂指标】");
			this.groovy.setValue("1");
			
			var html =  this.codemirror.getValue(); 
			Ext.getCmp('mytextarea').setValue(html);
			this.groovyCode.setValue(html);	
		}
		this.close();
	}
	
});
